package com.toby.demo.quickfixj;

import java.util.Scanner;

import com.toby.demo.quickfixj.receiver.FIXReceiver;

import quickfix.Application;
import quickfix.ConfigError;
import quickfix.DefaultMessageFactory;
import quickfix.FileStoreFactory;
import quickfix.LogFactory;
import quickfix.MessageFactory;
import quickfix.MessageStoreFactory;
import quickfix.ScreenLogFactory;
import quickfix.SessionSettings;
import quickfix.SocketAcceptor;

public class ReceiverApp {

	public static void main(String[] args) throws ConfigError {
		SessionSettings settings = new SessionSettings("receiver.cfg");
		Application application = new FIXReceiver();
		MessageStoreFactory messageStoreFactory = new FileStoreFactory(settings);
		// LogFactory logFactory = new FileLogFactory(settings);
		LogFactory logFactory = new ScreenLogFactory(settings);
		MessageFactory messageFactory = new DefaultMessageFactory();
		SocketAcceptor acceptor = new SocketAcceptor(application,
				messageStoreFactory, settings, logFactory, messageFactory);
		acceptor.start();
		Scanner scanner = new Scanner(System.in);
		System.out.println("Press <enter> to quit");
		scanner.nextLine();
		scanner.close();
		acceptor.stop();
	}

}
